#include "../include/head.h"
//创建带头的一个单链表
p_list create()
{
    p_list head = (p_list)malloc(sizeof(list_t));
    if(head == NULL)
    {
        printf("malloc failed!\n");
        return NULL;
    }
    head->next = NULL;
    return head;
}
// 插入一个节点
int insert(p_list head, ElemType data)
{
    p_list p = (p_list)malloc(sizeof(list_t));
    if(p == NULL)
    {
        printf("malloc failed!\n");
        return -1;
    }
    p->data = data;
    p->next = head->next;
    head->next = p;
    return 0;
}
//链表遍历
int show(p_list head)
{
    p_list p = head->next;
    for(int i=0;i<50;i++)printf("-");
    printf("\n");
 char *str[]={"学号","姓名","年龄","性别","班级","分数","专业","院系"};
    for(int i=0;i<8;i++)
    {
        printf("%8s|",str[i]);
    }
    printf("\n");
    int i=0;
    while(p != NULL&&i<5)
    {
       // printf("%s %d %d\n",p->data.name,p->data.age,p->data.id); 
       printf("%8d|",p->data.id);
       printf("%8s|",p->data.name);
       printf("%8d|",p->data.age);
       printf("\n");
        p = p->next;
        i++;
    }
    for(int i=0;i<50;i++)printf("-");
    printf("\n");
    return 0;
}